# Author:Yiye
# -*- codeing = utf-8 -*-
# @Time :2021/11/12 20:12
# @Author:李卓
# @Site : 
# @File : handler.py
# @Software : PyCharm
import urllib.request

url = 'http://www.baidu.com'
headers = {
    'User-Agent': ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
}
request = urllib.request.Request(url=url,headers=headers)
handler = urllib.request.HTTPHandler()
opener = urllib.request.build_opener(handler)
response = opener.open(request)
content = response.read().decode('utf-8')
print(content)